Repository navigation
Support manual Megatron restarts with retained serving - #2444
Merged
Merged
Conversation
Give internal serving a detached owner for engines, routers, GPU placements and the Straw controller. Use the same startup path with health checks on or off, persist Megatron replay state for Straw/debug transport, and rebuild failed managers against retained serving. Preserve external deployment and custom hook contracts. Cover manager death, driver fencing, source progress, checkpoint handoff and batch replay across changed trainer parallelism. Register all three manager restart scenarios in the generated GPU CI matrix. Validation: 291 CPU cases and three four-H100 restart e2e scenarios passed. Re-ran the 35 recovery and 75 transport cases after final cleanup; all pre-commit hooks and e2e artifact assertions passed.
Always monitor internal serving and force health checks at rollout boundaries. Remove dead router workers independently of their engine actors before abort or offload, then recover missing engines before the next weight update. Keep the external-serving policy and compatibility flag, use a 600-second background interval, and bound health/shutdown HTTP and Ray waits. Add CI e2e coverage for stale registrations after HTTP server and Ray actor crashes. Validated with 251 CPU tests, both 4-H100 crash e2e cases, a 3-engine PipelineRL continuity regression, and all pre-commit checks.
Keep topology and health monitoring in ServingCluster. Use engine snapshots for rollout memory controls, make finish_rollout explicit, remove duplicate monitoring and control forwarding, and include the update lock in startup. Document session lookup, resource ownership and the critical control ordering. Journal accepted batches and their source cursor together. Recover only missing engines so reusing a live manager preserves the replacement trainer's connection markers. Register the retained-manager restart scenario in CI. Validation: 348 CPU regressions, 253 final core regressions, all pre-commit checks, and seven H100 e2e scenarios covering manager replacement/reuse, server/actor crashes, PipelineRL continuity and mixed-model offload/recovery.
zhuzilin
force-pushed
the
zilin/restart-megatron
branch
from
October 6, 2026 05:03
6a0fb01 to
5f8faf0
Compare
A manager can die after Straw accepts a collection but before the training recovery journal records it. Reconcile that accepted receipt before recovering the old readers so replay preserves the original selection instead of conflicting with the completed collection. Add two-node Ray SIGKILL coverage for raw acceptance and converted batches, with online GC enabled and disabled, and verify repartitioning from DP=1 to DP=2. Cover restart before initial model loading, update checkpoint tests for the train entry point, and register the new test in CI. Validation: 4 new process-recovery e2e cases and 167 related regression tests passed. The existing 4-GPU Qwen2.5-0.5B recovery e2e also passed with a real OOM at rollout 1, manager death during training, TP=1 to TP=2, DP=2 to DP=1, two replayed batches, and retained SGLang engines. Black, isort and git diff --check passed.
Bound engine reattachment and retire stalled peers, preserve disk-delta baselines across trainer restarts, and freeze retained rollout inputs. Use queue receipts as the acceptance authority, keep only the checkpoint replay window, and share one converted batch through DP index views. Move async worker ownership to the data source without changing custom hooks. Support stateless Adam recovery without optimizer tensors by committing its scheduler with the model. Keep ordinary Adam optimizer/RNG requirements and reuse DDP callbacks across rollouts. No changes to the Megatron-LM dependency. Validation: 419 CPU regression cases, 11 Ray fault cases, and 6 GPU recovery scenarios including disk-delta, PD with a stalled engine, and MoE/R3. A Qwen3-30B-A3B benchmark on 32 H100 GPUs with 256 configured concurrency reduced the DP phase from 3.10 s to 0.096 s; global publication takes 1.92 s. These phase measurements do not imply an end-to-end training speedup.
Keep attempt teardown with the driver and release serving resources despite manager failures. Preserve requested configuration through explicit checkpoint and resume handoffs. Reset all PD weight-update peers before waiting, and separate cleanup deadlines from the 600-second health defaults.
mzopedia
added a commit
to mzopedia/slime
that referenced
this pull request
Oct 8, 2026
Evaluation runs on the source-owned worker that THUDM#2444 introduced; a distributed worker still rejects evaluation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Allow a failed Megatron training job to restart on the same Ray cluster while retaining healthy SGLang engines, routers, and accepted rollout data. The new trainer can change its parallel layout and replay the batches after the last committed checkpoint without regenerating samples or repeating accepted reward postprocessing.
Replay uses Straw storage (
--rollout-data-transport straw) or per-rollout debug dumps (--save-debug-rollout-datawith{rollout_id}in the path). Internal serving retention does not require the legacy--use-fault-toleranceflag.The PR also makes recovery ownership explicit, publishes each converted training batch once, fixes restored disk-delta weight updates, and bounds cleanup independently of normal training and storage operations.
Changes
Serving and training lifetimes
ServingClusterthat owns routers, engines, placement groups, the queue controller, and the weight-update lock.RolloutManagerborrows those resources and can be replaced independently.Checkpoint and replay ownership
TrainingResume; keep long-lived data-source configuration separate from each trainer attempt.Shared batch publication
Engine recovery and weight synchronization
overlap_grad_reduce.Optimizer state and defaults
--use-stateless-adam --no-save-optim. Save and restore the LR/WD scheduler alongside the model; require RNG state and validate the scheduler sidecar before accepting the checkpoint./root/Megatron-LMis unchanged.--rollout-health-check-timeoutand--rollout-health-check-first-waitto 600 seconds by default.--rollout-cleanup-timeout, default 60 seconds, for exiting an attempt. It does not limit normal data reads, generation, training, or checkpoint writes.Validation
Regression and fault tests
Lifecycle/configuration validation recorded for commit
8a6406bd.The lifecycle/configuration follow-up passed 443 distinct regression cases across training recovery, argument validation, Straw transport, fully asynchronous/distributed rollout, optional Straw dependencies, engine control, and score centering. Repeated verification runs are not added to this count.
The 12-case real-Ray manager recovery suite additionally covers:
Tests also check partial-startup rollback, cleanup error propagation, checkpoint selection without mutating requested paths, and unchanged args-based custom data-source construction.
Commands used for the final regression suites:
Existing test files remain registered in
.github/workflows/pr-test.yml.j2; this follow-up adds cases to those files rather than new matrix entries.GPU recovery
Validation used a four-host cluster with 8 H100 GPUs per host and shared JuiceFS storage.
The original recovery validation passed six GPU scenarios covering disk-delta updates, PD engine failure, object-store fully asynchronous rollout, ordinary Adam with overlapping gradient reduction, dense stateless Adam, and MoE stateless Adam with R3.
The lifecycle/configuration changes were also exercised with:
Large-MoE recovery uses stateless Adam; ordinary Adam recovery is covered by the dense-model scenarios.
Batch-publication measurement
Measured Qwen3-30B-A3B on 32 H100s: 16 training GPUs, 16 serving GPUs, configured serving concurrency 256, 256 samples per rollout, 1,024 generated tokens per sample, four rollouts, and R3 enabled. TP=2, EP=8, DP=8.
These are phase means. The DP phase becomes about 32.1× faster because it builds selections over one published batch. This is not an end-to-end throughput speedup; the revised global-publication cost is reported separately. R3 routes were nonempty and fully consumed during the measured training runs.
Scope and limitations